<!--
 * @Author: songleiluo 361215740@qq.com
 * @Date: 2024-01-14 10:42:28
 * @LastEditors: songleiluo 361215740@qq.com
 * @LastEditTime: 2024-01-14 16:49:02
 * @FilePath: \dxhospital\src\pages\patient\patientManagement.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>

<div class="patient-management">
    <div class="patient-menagement-operate-btns">
        <el-button type="primary" @click="create">新建</el-button>
        <el-button type="primary">删除</el-button>
    </div>
    <div class="patient-menagement-table"> 
        <el-table
    ref="multipleTableRef"
    :data="tableData"
    style="width: 100%"
    @selection-change="handleSelectionChange"
  >
    <el-table-column type="selection" width="55" />
    <el-table-column label="Date" width="120">
      <template #default="scope">{{ scope.row.date }}</template>
    </el-table-column>
    <el-table-column property="name" label="Name" width="120" />
    <el-table-column property="address" label="Address" show-overflow-tooltip />
    <el-table-column  label="操作" width="120">
      <template #default>
        <el-button link type="primary" size="small" @click="handleClick"
          >删除</el-button
        >
        <el-button link type="primary" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>
    </div>
</div>

</template>

<script lang="ts" setup >
import { ref } from 'vue'
import { ElTable } from 'element-plus'
import {useRouter} from 'vue-router'
interface User {
  date: string
  name: string
  address: string
}

// 2. 调用useRouter函数
const $r = useRouter();

const multipleTableRef = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref<User[]>([])
    const toggleSelection = (rows?: User[]) => {
  if (rows) {
    rows.forEach((row) => {
      // TODO: improvement typing when refactor table
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-expect-error
      multipleTableRef.value!.toggleRowSelection(row, undefined)
    })
  } else {
    multipleTableRef.value!.clearSelection()
  }
}
const handleSelectionChange = (val: User[]) => {
  multipleSelection.value = val
}
const tableData: User[] = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-08',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-06',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-07',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]

const handleClick = () => {
  console.log('click')
}

const create=()=>{
    $r.push({ path: '/index/create' })
}
</script>

<style scoped lang='scss'>
.patient-management{

    width:100%;
    height: 100%;
}

.patient-menagement-operate-btns{
    display: flex;
}
</style>